package thefirst.support.model;

import java.sql.SQLException;
import java.util.List;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;
@Repository
public class HelpDaoImpl implements HelpDao {
	@Resource(name="sqlSessionTemplate")
	private SqlSessionTemplate sqlSessionTemplate;
	/**
	 * 문의하기 글쓰기 -> DB에 insert
	 */
	@Override
	public void writeHelp(HelpVO hvo) throws SQLException {
		// TODO Auto-generated method stub
		sqlSessionTemplate.insert("help.writeHelp",hvo);
	}
	/**
	 * 문의하기 DB에 업데이트
	 */
	@Override
	public int updateHelp(HelpVO hvo) throws SQLException {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.update("help.updateHelp", hvo);
	}
	/**
	 * 문의하기 DB에 삭제
	 */
	@Override
	public void deleteHelp(int no) throws SQLException {
		// TODO Auto-generated method stub
		sqlSessionTemplate.delete("help.deleteHelp", no);
	}
	/**
	 * 글번호로 DB에 저장된 정보 가져오기
	 */
	@Override
	public HelpVO showHelpInfoNoHits(int no) throws SQLException {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.selectOne("help.showHelpInfoNoHits",no);
	}
	/**
	 * 글번호로 게시글 리스트로 가져오기
	 */
	@Override
	public List<HelpVO> getHelpList(String pageNo) throws SQLException {
		return sqlSessionTemplate.selectList("help.getHelpList",pageNo);
	}
	/**
	 * 총 게시글 수
	 */
	@Override
	public int totalHelpContent() throws SQLException {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.selectOne("help.totalHelpContent");
	}
	/**
	 * 조회수 올리기
	 */
	@Override
	public int updateHits(int no) throws SQLException {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.update("help.updateHits",no);
	}

	/*@Override
	public int selectHelpRef(int no) throws SQLException {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.selectOne("help.selectHelpRef",no);
	}*/
	/**
	 * 댓글쓰기를 위해 스텝과 레벨을 업데이트
	 */
	@Override
	public int updateHelpForWritingReply(HelpVO hvo) throws SQLException {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.update("help.updateHelpForWritingReply",hvo);
	}
	/**
	 * 댓글 DB에 저장
	 */
	@Override
	public int writeHelpReply(HelpVO hvo) throws SQLException {
		// TODO Auto-generated method stub
		return sqlSessionTemplate.insert("help.writeHelpReply",hvo);
	}

}
